import Vue from "vue";
import Router from "vue-router";
import creditXZL from './components/querenxuanhao/xia.vue'

import { getToken } from "./util/token";

Vue.use(Router);

let router = new Router({
  // redirect重定向
  // meta 可以在页面中用$route.meta来获取里面的数据
  routes: [
    {
      path: "/",
      redirect: "/wuxingfushi"
    },
    // 登录
    {
      path: "/login",
      name: "login",
      component: () =>
        import(/* webpackChunkName: "login" */ "./components/login/login"),
      meta: {
        requiresAuth: false
      }
    },
    // 注册
    {
      path: "/register",
      name: "register",
      component: () =>
        import(
          /* webpackChunkName: "register" */ "./components/register/register"
        ),
      meta: {
        requiresAuth: false
      }
    },
    // 忘记密码
    {
      path: "/wangjimima",
      name: "wangjimima",
      component: () =>
        import(
          /* webpackChunkName: "wangjimima" */ "./components/wangjimima/wangjimima"
        ),
      meta: {
        requiresAuth: false
      }
    },
    //走势图
    {
      path: "/zoushitu",
      name: "zoushitu",
      component: () => import("./components/zoushitu/zoushitu"),
      meta: {
        requiresAuth: false,
        title: "走势图",
        header: true,
        footer: false,
        fan: 1
      }
    },
    //充值
    {
      path: "/chongzhi",
      name: "chongzhi",
      component: () =>
        import(/* webpackChunkName: "card" */ "./components/chongzhi/chongzhi"),
      meta: {
        requiresAuth: false,
        title: "充值",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //提现
    {
      path: "/tixian",
      name: "tixian",
      component: () =>
        import(/* webpackChunkName: "card" */ "./components/tixian/tixian"),
      meta: {
        requiresAuth: false,
        title: "提现",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //个人资料
    {
      path: "/gerenziliao",
      name: "gerenziliao",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/ziliao/gerenziliao"
        ),
      meta: {
        requiresAuth: false,
        title: "个人资料",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //银行卡管理
    {
      path: "/yinkangka",
      name: "yinkangka",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/guanlika/yinkangka"
        ),
      meta: {
        requiresAuth: false,
        title: "银行卡管理",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //彩种限额
    {
      path: "/caizhong",
      name: "caizhong",
      component: () =>
        import(/* webpackChunkName: "card" */ "./components/xiane/caizhong"),
      meta: {
        requiresAuth: false,
        title: "彩种限额",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //帐变记录
    {
      path: "/zhangbian",
      name: "zhangbian",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/zhangbian/zhangbian"
        ),
      meta: {
        requiresAuth: false,
        title: "帐变记录",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //充值记录
    {
      path: "/chongzhijilu",
      name: "chongzhijilu",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/jiluchongzhi/chongzhijilu"
        ),
      meta: {
        requiresAuth: false,
        title: "充值记录",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //提现记录
    {
      path: "/tixianjilu",
      name: "tixianjilu",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/jilutixian2/tixianjilu"
        ),
      meta: {
        requiresAuth: false,
        title: "提现记录",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //登录密码
    {
      path: "/denglumima",
      name: "denglumima",
      component: () =>
        import(/* webpackChunkName: "card" */ "./components/mima/denglumima"),
      meta: {
        requiresAuth: false,
        title: "登录密码",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //交易密码
    {
      path: "/jiaoyimima",
      name: "jiaoyimima",
      component: () =>
        import(/* webpackChunkName: "card" */ "./components/mima/jiaoyimima"),
      meta: {
        requiresAuth: false,
        title: "交易密码",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //公告信息
    {
      path: "/gonggaoxinxi",
      name: "gonggaoxinxi",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/gonggaoxinxi/gonggaoxinxi"
        ),
      meta: {
        requiresAuth: false,
        title: "公告信息",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //问题反馈
        {
      path: "/feedback",
      name: "feedback",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/feedback/feedback"
        ),
      meta: {
        requiresAuth: false,
        title: "问题反馈",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    // 公告详情
    {
      path: "/gonggaoxiangqing/:id",
      name: "gonggaoxiangqing",
      component: () =>
        import(
          /* webpackChunkName: "card" */ "./components/gonggaoxinxi/gonggaoxiangqing"
        ),
      meta: {
        requiresAuth: false,
        title: "公告详情",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      }
    },
    //玩法说明
    {
      path: "/wanfashuoming",
      name: "wanfashuoming",
      component: () =>
        import("./components/wanfashuoming/wanfashuoming"
        ),
      meta: {
        requiresAuth: false,
        title: "玩法说明",
        header: true, //头部
        footer: false, //底部
        fan: 1 //这个返回按钮1显示 0隐藏
      },
      children: [
        {
          path: "",
          redirect: "/guanfangwen"
        },
        //官方玩法说明
        {
          path: "/guanfangwen",
          name: "guanfangwen",
          component: () =>
            import(
              /* webpackChunkName: "wangjimima" */ "./components/wanfashuoming/guanfangwen"
            ),
          meta: {
            requiresAuth: false,
            title: "玩法说明",
            header: true, //头部
            footer: false, //底部
            fan: 1 //这个返回按钮1显示 0隐藏
          }
        },
        //信用玩法说明
        {
          path: "/xinyongwen",
          name: "xinyongwen",
          component: () =>
            import(
              /* webpackChunkName: "wangjimima" */ "./components/wanfashuoming/xinyongwen"
            ),
          meta: {
            requiresAuth: false,
            title: "玩法说明",
            header: true, //头部
            footer: false, //底部
            fan: 1 //这个返回按钮1显示 0隐藏
          }
        }
      ]
    },



    // 首页    		首页 index两个子组件 官方玩法与信用卡玩法
    {
      path: "/home",
      name: "home",
      component: () =>
        import(/* webpackChunkName: "index" */ "./components/index/home"),
      meta: {
        requiresAuth: false
      },
      redirect: "wuxingfushi",
      //所有的子组件  内容
      children: [
        {
          // 官方玩法or 信用玩法
          path: "/:playMethods",
          component: () =>
            import("./components/index/components/playMethods.vue"),
          children: [
            // 五星复式
            {
              path: "/wuxingfushi",
              name: "wuxingfushi",
              component: () => import("./components/wuxingwanfa/wuxingfushi"),
              meta: {
                requiresAuth: false,
                playType: "五星直选复式"
              }
            },
            //五星单式
            {
              path: "/wuxingdanshi",
              name: "wuxingdanshi",
              component: () => import("./components/wuxingwanfa/wuxingdanshi"),
              meta: {
                requiresAuth: false,
                playType: "五星直选单式"
              }
            },
            //五星组合
            {
              path: "/wuxingzuhe",
              name: "wuxingzuhe",
              component: () => import("./components/wuxingwanfa/wuxingzuhe"),
              meta: {
                requiresAuth: false,
                playType: "五星直选组合"
              }
            },
            //------趣味玩法-----
            //一帆风顺
            {
              path: "/yifanfengshun",
              name: "yifanfengshun",
              component: () => import("./components/quweiwanfa/yifanfengshun"),
              meta: {
                requiresAuth: false,
                playType: "趣味一帆风顺"
              }
            },
            //好事成双
            {
              path: "/chengshuang",
              name: "chengshuang",
              component: () => import("./components/quweiwanfa/chengshuang"),
              meta: {
                requiresAuth: false,
                playType: "趣味好事成双"
              }
            },
            //三星报喜
            {
              path: "/sanbaoxi",
              name: "sanbaoxi",
              component: () => import("./components/quweiwanfa/sanbaoxi"),
              meta: {
                requiresAuth: false,
                playType: "趣味三星报喜"
              }
            },
            //四季发财
            {
              path: "/facai",
              name: "facai",
              component: () => import("./components/quweiwanfa/facai"),
              meta: {
                requiresAuth: false,
                playType: "趣味四季发财"
              }
            },
            //前三直选复式
            {
              path: "/qianfushi",
              name: "qianfushi",
              component: () => import("./components/qiansanwanfa/qianfushi"),
              meta: {
                requiresAuth: false,
                playType: "前三直选复式"
              }
            },
            //前三直选单式
            {
              path: "/qianridio",
              name: "qianridio",
              component: () => import("./components/qiansanwanfa/qianridio"),
              meta: {
                requiresAuth: false,
                playType: "前三直选单式"
              }
            },
            //前三直选和值
            {
              path: "/qianhezhi",
              name: "qianhezhi",
              component: () => import("./components/qiansanwanfa/qianhezhi"),
              meta: {
                requiresAuth: false,
                playType: "前三直选和值"
              }
            },
            //中三直选复式
            {
              path: "/zhongfushi",
              name: "zhongfushi",
              component: () =>
                import(
                  /* webpackChunkName: "wangjimima" */ "./components/zhongsanwanfa/zhongfushi"
                ),
              meta: {
                requiresAuth: false,
                playType: "中三直选复式"
              }
            },
            //中三直选单式
            {
              path: "/zhongridio",
              name: "zhongridio",
              component: () => import("./components/zhongsanwanfa/zhongridio"),
              meta: {
                requiresAuth: false,
                playType: "中三直选单式"
              }
            },
            //中三直选和值
            {
              path: "/zhonghezhi",
              name: "zhonghezhi",
              component: () => import("./components/zhongsanwanfa/zhonghezhi"),
              meta: {
                requiresAuth: false,
                playType: "中三直选和值"
              }
            },
            //后三直选复式housanwanfa1
            {
              path: "/houfushi",
              name: "houfushi",
              component: () => import("./components/housanwanfa/houfushi"),
              meta: {
                requiresAuth: false,
                playType: "后三直选复式"
              }
            },
            //后三直选单式
            {
              path: "/houridio",
              name: "houridio",
              component: () => import("./components/housanwanfa/houridio"),
              meta: {
                requiresAuth: false,
                playType: "后三直选单式"
              }
            },
            //后三直选和值
            {
              path: "/houhezhi",
              name: "houhezhi",
              component: () => import("./components/housanwanfa/houhezhi"),
              meta: {
                requiresAuth: false,
                playType: "后三直选和值"
              }
            },
            //第一个整合玩法
            {
              path: "/zhenghe",
              name: "zhenghe",
              component: () => import("./components/xinyongkaa/zhenghe"),
              meta: {
                requiresAuth: false,
                playType: "整合"
              }
            },
            //第二个龙虎斗玩法
            {
              path: "/longhudou",
              name: "longhudou",
              component: () => import("./components/xinyongkaa/longhudou"),
              meta: {
                requiresAuth: false,
                playType: "龙虎斗"
              }
            },
            //第三个全5中1
            {
              path: "/wuzhongyi",
              name: "wuzhongyi",
              component: () => import("./components/xinyongkaa/wuzhongyi"),
              meta: {
                requiresAuth: false,
                playType: "全5中1"
              }
            }
          ]
        },
        {
          path: "/gf/xiazhulan",
          name: "xiazhulan",
          // component: XZL,
          component: () =>
            import(
              /* webpackChunkName: "wangjimima" */ "./components/wuxingwanfa/xiazhulan"
            ),
          meta: {
            requiresAuth: false
          }
        },
        {
          path: "/credit/xiazhulan",
          name: "xia",
          component: creditXZL,
          // component: () =>
          //   import(
          //     /* webpackChunkName: "register" */ "./components/querenxuanhao/xia"
          //   ),
          meta: {
            requiresAuth: false
          }
        }
      ]
    }
  ]
});

// router.beforeEach((to, from, next) => {
//   // console.log(to)
//   if (to.matched.some(route => route.meta.requiresAuth)) {
//     if (!getToken()) {
//       next({
//         path: "/login"
//       });
//     } else {
//       next();
//     }
//   } else {
//     next();
//   }
// });

export default router;
